package com.erp.myAdapter

import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.erp.R
import com.erp.bean.FileBean
import kotlinx.android.synthetic.main.lv_tv_item.view.*

/**
 * Created by Administrator on 2019/4/16/016.
 * 作者：刘洋
 */
class FileAdapter(var context: Context, var list : MutableList<FileBean>, var isadd : Boolean) : BaseAdapter(){
    private val minflater: LayoutInflater = LayoutInflater.from(context)
    @SuppressLint("ViewHolder")
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        val v :View = minflater.inflate(R.layout.lv_tv_item, null)
        if (position == list.size) {
            v.tv_lv_item.text = "添加文件"
        } else {
            v.tv_lv_item.text=list[position].filename
        }
        return v
    }

    override fun getItem(position: Int): Any {
        return list[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getCount(): Int {
        if (isadd){
            return list.size+1
        }else{
            return list.size
        }
    }

    fun Allnotify(list : MutableList<FileBean>){
        this.list=list
        notifyDataSetChanged()
    }

}
